package com.mydroidchat.data;

public class ChatMessage {
    private ChatUser user;
    private String text;
    private Long date;

    public ChatMessage(Long date, String text, ChatUser user) {
        this.date = date;
        this.text = text;
        this.user = user;
    }

    public Long getDate() {
        return date;
    }

    public String getText() {
        return text;
    }

    public ChatUser getUser() {
        return user;
    }

    @Override
    public int hashCode() {
        return toString().hashCode();
    }

    @Override
    public String toString() {
        return user.getNick() + ": " + text;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof ChatMessage)) {
            return false;
        }
        return /*date.equals(((ChatMessage) obj).getDate()) && */user.equals(((ChatMessage) obj).getUser()) && text.equals(((ChatMessage) obj).getText());
    }
}
